package com.lqian.demo02.part1;

import com.lqian.demo02.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @author：Melody_LQ
 * @time：2022/7/13 2:31 下午
 */
public class TestUpdateDemo {

    public static void main(String[] args) {
        Connection conn = null;
        Statement st = null;
        ResultSet rs = null;

        try {
            conn = JDBCUtils.getConnection();
            st = conn.createStatement();
            String sql = " update users set name = 'jack',email='2222222.@qq.com' where id = 3 ";
            int resultRow = st.executeUpdate(sql);
            if (resultRow >0){
                System.out.println("更改成功！");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            JDBCUtils.release(conn,st,rs);
        }
    }
}
